/**
 * Created by yangfan on 2017/4/12.
 */

define(['config/appregister',"business/index/services/httpServices","jquery"],function(app,httpService){
    app.directive("engSpecial",function(){
        return {
            templateUrl:"app/business/index/template/engSpecial.html",
            scope:{
              data:'='
            },
            link:function(scope,element,attrs){
                var w=290+13;
                scope.$apply(function(){
                    $('.banner-container').css('width',w*(scope.data.length)-13);
                    scope.len=Math.ceil(scope.data.length/4);
                });
                //轮播
                function Play(){
                    var i= 0;
                    this.move=function(dir,len,width){
                        if(dir=='next'){i++;}
                        if(dir=='pre'){i--;}
                        if(i>=len){i=1;}//$('.banner-container').css('marginLeft',0)
                        if(i<=0){i=0;}//$('.banner-container').css('marginLeft',-width*len)
                        $('.banner-container').stop().animate({marginLeft:-width*i},600);
                    }
                }
                var bannerPaly=new Play();
                scope.dirction=function(dir){
                    bannerPaly.move(dir,scope.len,w);
                };

            }
        }
    });
});
